home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 4503 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: walt.tsc.com!not-for-mail
  2. From: billr@elmer.tsc.com (Bill Roberts)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: x ^= y ^= x ^= y;
  5. Date: 29 Feb 1996 14:03:34 -0500
  6. Organization: Technology Service Corporation
  7. Sender: Bill Roberts
  8. Message-ID: <4h4ta6$ivf@elmer.tsc.com>
  9. References: <4glcf7$eou@wn1.sci.kun.nl> <972.6628T1080T1212@cs.ruu.nl>
  10. NNTP-Posting-Host: elmer.tsc.com
  11.  
  12. In article <972.6628T1080T1212@cs.ruu.nl>,
  13. Wessel Dankers <wsldanke@cs.ruu.nl> wrote:
  14. !
  15. !Olaf Seibert <rhialto@mbfys.kun.nl> wrote:
  16. !>> x ^= y ^= x ^= y;
  17. !
  18.    <snip statement that you can't do this and why>
  19. !
  20. !It has been tested and used. Remember that the ^= is right associative:
  21. !read it as:
  22. !
  23. !x ^= (y ^= (x ^= y));
  24. !
  25. !The result-value of (x ^= y) is equal to the new value of x, mutatis mutandis
  26. !for (y ^= x).
  27. !
  28. The result of the evaluations is done in the order you have shown.
  29. The storage does not have to be done in the order shown.  Therefore, x
  30. could end up with either of the value of the first xor or the second
  31. xor.  The same for y.  It may work on the compiler you are using.  It
  32. may not work on another equally correct compiler.  This case is
  33. specifically stated as producing undefined results in the ANSI C
  34. standard.  The comp.lang.c FAQ's specifically discuss this problem and
  35. why it is undefined.
  36.